{* $Id$ *}
{include_core file="admin/lib/header.html" title="任务管理"}
  <div class="page-header border-bottom clearfix">
    <h2 class="left">任务管理<span>任务列表</span></h2>
    <a href="{AnUrl("dahuaxiyou/admin/export")}" class="btn btn-success btn-sm right">导出EXCEL</a>
    <a href="{AnUrl("dahuaxiyou/admin/download")}?topic_name=dahuaxiyou" class="btn btn-success btn-sm right">图片打包下载</a>
  </div>

<div class="search-form js_advancedForm">
  <form action="{AnUrl("dahuaxiyou/admin")}" method="get" class="js_focusSearchForm">
    <input type="hidden" name="image" value="1">
    <p>
    <label for="" class="search-f-label" >合伙人名称：</label>
    <input type="text" class="search-f-ipt1" style="height:20px" name="search_filter[dealer_name]" value="{$search_filter.dealer_name}" id="dealer_name">
    </p>
    <p>
      <label for="" class="search-f-label">店铺名称：</label>
      <input type="text" class="search-f-ipt1"  style="height:20px" name="search_filter[title]" value="{$search_filter.title}" id="store_name">
    </p>
    <p>
      <label for="" class="search-f-label">地区筛选：</label>
      <select name="search_filter[province_id]"  class="js_provinceList" style="width:120px;">
        <option value="0" selected="selected">请选择省份</option>
      </select>
      <select name="search_filter[city_id]"  class="js_cityList" style="width:120px;{if !$search_filter['city_id'] || $search_filter['city_id'] == '000000'}display:none;{/if}">
        <option value="0">请选择城市</option>
      </select>
      <select name="search_filter[district_id]" class="js_countyList" style="width:120px;{if !$search_filter['district_id'] || $search_filter['district_id'] == '000000'}display:none;{/if}">
        <option value="0">请选择区(县)</option>
      </select>
    </p>
    <p><label for="" class="search-f-label"></label><button type="submit" class="btn btn-success btn-xs js_searchBtn">搜索</button></p>
  </form>
</div>


  <!--<div class="search-level1 clearfix" {if $is_advenced == 1}style="display:none;"{/if}>-->
    <!--<form action="device/admin" method="get">-->
      <!--<input type="hidden" name="is_advenced" value="0">-->
      <!--<input type="hidden" name="status" value="{$status}">-->
      <!--<input type="text" class="left" name="search_filter[device_no]" value="{$search_filter.device_no}" placeholder="序列号">-->
      <!--<button type="submit" class="btn btn-success btn-sm left">搜索</button>-->
    <!--</form>-->
  <!--</div>-->

  <!--<div class="list-table-filters">-->
    <!--<p>-->
      <!--<span class="label label-info">按类型</span>-->
      <!--<a href='{AnUrl("device/admin?status=$status&res_name=machine")}' {if $res_name == 'machine'} class="label label-primary" {else} class="label label-default" {/if}>保温箱</a>-->
      <!--<a href='{AnUrl("device/admin?status=$status&res_name=adbox")}' {if $res_name == 'adbox'} class="label label-primary" {else} class="label label-default" {/if}>广告机</a>-->
      <!--<a href='{AnUrl("device/admin?status=$status&res_name=ibeacon")}' {if $res_name == 'ibeacon'} class="label label-primary" {else} class="label label-default" {/if}>外置摇一摇</a>-->
      <!--<a href='{AnUrl("device/admin?status=$status&res_name=game_table")}' {if $res_name == 'game_table'} class="label label-primary" {else} class="label label-default" {/if}>游戏桌</a>-->
    <!--</p>-->
    <!--<p>-->
      <!--<span class="label label-info">按状态</span>-->
      <!--<a href='{AnUrl("device/admin?status=-1&res_name={$res_name}")}' {if $status == -1} class="label label-primary" {else} class="label label-default" {/if}>全部</a>-->
      <!--{foreach machine_config::$status_list as $k => $v}-->
      <!--<a href='{AnUrl("device/admin?status={$k}&res_name={$res_name}")}' {if $status == $k} class="label label-primary" {else} class="label label-default" {/if}>{$v}</a>-->
      <!--{/foreach}-->
    <!--</p>-->
  <!--</div>-->
  <!--start:列表-->
  <table class="list-table">
    <caption>按状态：
      <a href='{AnUrl("dahuaxiyou/admin?status=-1&&search_filter[dealer_name]={$search_filter.dealer_name}&&search_filter[title]={$search_filter.title}&&search_filter[province_id]={$search_filter.province_id}&&search_filter[city_id]={$search_filter.city_id}&&search_filter[county_id]={$search_filter.county_id}")}'
         {if $status ==-1} class="label label-primary" {else} class="label label-default" {/if}>全部</a>
      <a href='{AnUrl("dahuaxiyou/admin?status=0&&search_filter[dealer_name]={$search_filter.dealer_name}&&search_filter[title]={$search_filter.title}&&search_filter[province_id]={$search_filter.province_id}&&search_filter[city_id]={$search_filter.city_id}&&search_filter[county_id]={$search_filter.county_id}")}'
         {if $status ==0} class="label label-primary" {else} class="label label-default" {/if}>未审核</a>
      <a href='{AnUrl("dahuaxiyou/admin?status=1&&search_filter[dealer_name]={$search_filter.dealer_name}&&search_filter[title]={$search_filter.title}&&search_filter[province_id]={$search_filter.province_id}&&search_filter[city_id]={$search_filter.city_id}&&search_filter[county_id]={$search_filter.county_id}")}'
         {if $status == 1} class="label label-primary" {else} class="label label-default" {/if}>已通过</a>
      <a href='{AnUrl("dahuaxiyou/admin?status=2&&search_filter[dealer_name]={$search_filter.dealer_name}&&search_filter[title]={$search_filter.title}&&search_filter[province_id]={$search_filter.province_id}&&search_filter[city_id]={$search_filter.city_id}&&search_filter[county_id]={$search_filter.county_id}")}'
         {if $status == 2} class="label label-primary" {else} class="label label-default" {/if}>已驳回</a>
    </caption>
    <thead>
      <tr>
        <th>序号</th>
        <th>门店头图</th>
        <th>上传时间</th>
        <th>照片</th>
        <th>合伙人id</th>
        <th>合伙人名称</th>
        <th>店铺id</th>
        <th>店铺名称</th>
        <th>店铺分支</th>
        <th>状态</th>
        <th style="min-width:60px;">操作</th>
      </tr>
    </thead>
    <tbody>
      {foreach $photo_list as $k=>$v}
        <tr id="dataList{$v.id}" {if $k%2 == 1} class="bg-gray"{/if} data-id="{$v.id}">
          <td>{$v.id}</td>
          <td><a href="{if $v['store_info']['cover']}{_image($v['store_info']['cover'])}{else}{store_helper::cover($v['store_info']['cover'])}{/if}" target="_blank">
            <img width="100" height="80" src="{if $v['store_info']['cover']}{_image($v['store_info']['cover'])}{else}{store_helper::cover($v['store_info']['cover'])}{/if}" /></a>
          </td>
          <td>{$v.upload_time}</td>
          <td>
       <!--        <img src="{store_helper::cover($v.src)}" style="width:100px;"> -->

            <a href="{if $v['src']}{_image($v['src'])}{else}{store_helper::cover($v['src'])}{/if}" target="_blank">
          <img width="100" height="80" src="{if $v['src']}{_image($v['src'])}{else}{store_helper::cover($v['src'])}{/if}" /></a>

          </td>
          <td>{$v.parent_id}</td>
          <td>{$v['dealer_info']['realname']}</td>
          <td>{$v.store_id}</td>
          <td>{$v['store_info']['title']}</td>
          <td>{$v['store_info']['title_branch']}</td>
          {if $v.status == 0}
          <td>未审核</td>
          {elseif $v.status == 1}
          <td>已通过</td>
          {elseif $v.status == 2}
          <td>已驳回</td>
          {/if}
          <td>
            {if $v.status == 0}
            <a href="{AnUrl("dahuaxiyou/admin/change_status?id={$v.id}&status=2")}" class="btn btn-warning btn-xs js_changeStatus"><i class="icon-trash icon-white"></i>驳回审核</a>
            <a href="{AnUrl("dahuaxiyou/admin/change_status?id={$v.id}&status=1")}" class="btn btn-info btn-xs js_changeStatus"><i class="icon-trash icon-white"></i>通过审核</a>
            {elseif $v.status == 1}
            <a href="{AnUrl("dahuaxiyou/admin/change_status?id={$v.id}&status=2")}" class="btn btn-warning btn-xs js_changeStatus"><i class="icon-trash icon-white"></i>驳回审核</a>

            {elseif $v.status == 2}
            <a href="{AnUrl("dahuaxiyou/admin/change_status?id={$v.id}&status=1")}" class="btn btn-info btn-xs js_changeStatus"><i class="icon-trash icon-white"></i>通过审核</a>
            {/if}
            </td>
        </tr>
      {foreachelse}
          <tr><td class="txtleft" colspan="9">暂无数据</td></tr>
      {/foreach}
    </tbody>
  </table>
  <script type="text/javascript">

    //初始化省份列表
    $.ajax({
      url : 'area/admin/ajax_get_provinces',
      type : 'get',
      dataType : 'json',
      success : function(province_list){
        for (var i in province_list) {
          var opt = $('<option value="'+province_list[i]['area_code']+'">'+province_list[i]['area']+'</option>');
          $('.js_provinceList').append(opt);
        }

        {if $area['province_info']}
        $('.js_provinceList').val("{$area['province_info']['area_code']}");
        //触发请求
        $('.js_provinceList').change();
        {/if}

        {if $area['city_info']}
        $('.js_provinceList').val("{$area.province_info.area_code}");
        $('.js_cityList').val("{$area.city_info.area_code}");
        $('.js_cityList').change();
        $('.js_countyList').val("{$area['county_info']['area_code']}");
        {/if}
      }
    });

    $(function(){
      $('.js_provinceList').change(function(){
        //获取值
        if($(this).val() !== '0'){
          var province = $(this).val();
          $('.js_cityList').slideDown();
          $('.js_cityList').val('0');
          $('.js_countyList').slideUp();
          $('.js_countyList').val('0');
        }else{
          $('.js_cityList').slideUp();
          $('.js_countyList').slideUp();
          $('.js_countyList').val('0');
          $('.js_cityList').val('0');
          return false;
        }
        $('.js_cityList').empty();
        $('.js_cityList').append('<option value="0">请选择城市</option>');
        $('.js_countyList').empty();
        $('.js_countyList').append('<option value="0">请选择区(县)</option>');

        //发送ajax
        $.ajax({
          url : 'area/admin/ajax_get_citys?province_code='+province,
          success : function(city_list){
            for (var i in city_list) {
              var opt = $('<option value="'+city_list[i]['area_code']+'">'+city_list[i]['area']+'</option>');
              $('.js_cityList').append(opt);
            }

            {if $area.city_info}
            $('.js_cityList').val("{$area.city_info.area_code}");
            {/if}
          },
          type : 'get',
          dataType : 'json',
          async : false,
        });


      });
      //城市
      $('.js_cityList').change(function(){
        if ( $('.js_provinceList').val() === '0' || $('.js_cityList').val() === '0') {
          $('.js_countyList').slideUp();
          $('.js_countyList').val('0');
          return false;
        } else {
          $('.js_countyList').slideDown();
          $('.js_countyList').val('0');
        }

        $('.js_countyList').empty();
        $('.js_countyList').append('<option value="0">请选择区(县)</option>');

        //获取省份的key和值
        var province_code = $('.js_provinceList').val();
        var pro_text = $('.js_provinceList').text();

        //获取城市的值
        var city_code = $(this).val();

        //发送ajax
        $.ajax({
          url : 'area/admin/ajax_get_countys?province_code='+province_code+'&city_code='+city_code,
          type : 'get',
          dataType : 'json',
          success : function(county_list){
            for (var i in county_list) {
              var opt = $('<option value="'+county_list[i]['area_code']+'">'+county_list[i]['area']+'</option>');
              $('.js_countyList').append(opt);
            }

            {if $area['county_info']}
            $('.js_countyList').slideDown();
            $('.js_countyList').val("{$area['county_info']['area_code']}");
            {/if}
          }
        });

      });




        //导出
      $('#export').click(function(){

        var export_date =  $('#export_date').val();
        //发送ajax
        $.ajax({
          url : 'dahuaxiyou/admin/export?export_date='+ export_date,
          success : function(){
          },
          type : 'get',
          dataType : 'json',
          async : false,
        });
      });
    });

  $(function(){
    // 高级搜索
    $('.js_advanced').click(function(e){
      e.preventDefault();
      var thisObj = $(this);
      var outBox  = thisObj.closest('form');
      if (thisObj.hasClass('js_isOpen')) {
        thisObj.removeClass('js_isOpen open');
        outBox.find('input').show();
        outBox.find('button').show();
        $('.js_advancedForm').hide();
      } else {
        thisObj.addClass('js_isOpen open');
        outBox.find('input').hide();
        outBox.find('button').hide();
        $('.js_advancedForm').show();
      }
    });


    $(".js_changeStatus").live('click',function(e){
      e.preventDefault();
      e.stopPropagation();

      var notice = '确定执行此操作吗?';
      var clickObj = $(this);
      var url = clickObj.attr("href");

      showConfirm(notice, 1, function(){
        $.post(url, {}, function(json){
          if (json.info != 'ok') {
            alert(json.info);
          }
        }, 'json');
      });
      return false;
    });


    // 搜索
    $('.js_searchBtn').click(function(e){
      e.preventDefault();
      var thisObj   = $(this);
      var dealer_name = $.trim($('#dealer_name').val());
      var store_name  = $.trim($('#store_name').val());

      thisObj.closest('form').submit();
    });

  });
  </script>
  {include_core file="admin/lib/pager.html"}
<!--end:列表-->
{load_js file='zclip/jquery.zclip.min.js'}
{load_js file='zclip/ZeroClipboard.js'}
{include_core file="admin/lib/footer.html"}